import { request ,uploadFile} from './request.js'

export function userLogin(data){
  const { phone , password} = data;
  return request({
    url:`/users/login?phone=${phone}&&password=${password}`,
    method:'post'
  })
}

export function userRegister(data){
  return request({
    url:`/users/register`,
    data:data,
    method:'post'
  })
}

//上传文件
export function upload(data) {
   return request({
     url:'/upload',
     data:data,
     method:'post'
   })
}

//获取用户手机号
export function getPhone(data) {
  return request({
    url:`/users/getPhoneNumber?code=`+data,
    method:'post'
  })
}

//微信登录
export function wxLogin(data) {
  return request({
    url:`/users/wxLogin?code=`+data,
    method:'post'
  })
}

// 获取用户信息
export function getUser(){
  return request({
    url:'/users/getUserInfo'
  })
}

// 用户修改密码
export function changePassword(data){
  return request({
    url:'/users/changePassword',
    data:data,
    method:'put'
  })
}

// 上传文件
export function uploadFiles(filePath, formData = {}) {
  return uploadFile(filePath, formData);
}

// 获取轮播图列表
export function getBanners() {
  return request({
    url: '/users/banners/list'
  })
}

// 获取通知公告列表
export function getNotifications() {
  return request({
    url: '/users/notifications/list'
  })
}

// 获取新闻列表
export function getNewsList() {
  return request({
    url: '/users/news/list'
  })
}